Single domU, ping to dom0.
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Fri, 9 Dec 2005 10:40:28 +0000 (10:40 +0000)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Fri, 9 Dec 2005 10:40:28 +0000 (10:40 +0000)
Signed-off-by: Jim Dykman <dykman@us.ibm.com>
tools/xm-test/tests/network/05_network_dom0_ping_pos.py [new file with mode: 0644]

diff --git a/tools/xm-test/tests/network/05_network_dom0_ping_pos.py b/tools/xm-test/tests/network/05_network_dom0_ping_pos.py
new file mode 100644 (file)
index 0000000..b252c2d
--- /dev/null
@@ -0,0 +1,73 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author:  <dykman@us.ibm.com>
+
+# Ping tests to dom0 interface
+#  - determines dom0 network
+#  - creates a single guest domain
+#  - sets up a single NIC on same subnet as dom0
+#  - conducts ping tests to the dom0 IP address.
+
+# ping -c 1 -s $size $dom0_IP 
+#   where $size = 1, 48, 64, 512, 1440, 1500, 1505, 
+#                 4096, 4192, 32767, 65507, 65508
+
+pingsizes = [ 1, 48, 64, 512, 1440, 1500, 1505, 4096, 4192, 
+                32767, 65507 ]
+
+
+
+from XmTestLib import *
+rc = 0
+
+Net = XmNetwork()
+
+try:
+    # read an IP address from the config
+    ip     = Net.ip("dom1", "eth0")
+    mask   = Net.mask("dom1", "eth0")
+except NetworkError, e:
+        FAIL(str(e))
+
+# Fire up a guest domain w/1 nic
+domain = XmTestDomain(extraOpts={ 'nics' : 1 })
+try:
+    domain.configSetVar('vif', " [ 'ip=" + ip + "' ]")
+    domain.start()
+except DomainError, e:
+    if verbose:
+        print "Failed to create test domain because:"
+        print e.extra
+    FAIL(str(e))
+
+
+# Attach a console
+try:
+    console = XmConsole(domain.getName(), historySaveCmds=True)
+    # Activate the console
+    console.sendInput("bhs")
+except ConsoleError, e:
+    FAIL(str(e))
+
+try:
+    # Add a suitable dom0 IP address 
+    dom0ip = Net.ip("dom0", "eth0", todomname=domain.getName(), toeth="eth0")
+except NetworkError, e:
+        FAIL(str(e))
+
+try:
+    console.runCmd("ifconfig eth0 inet "+ip+" netmask "+mask+" up")
+
+    # Ping dom0
+    fails=""
+    for size in pingsizes:
+        out = console.runCmd("ping -q -c 1 -s " + str(size) + " " + dom0ip)
+        if out["return"]:
+            fails += " " + str(size) 
+except ConsoleError, e:
+        FAIL(str(e))
+
+if len(fails):
+    FAIL("Ping to dom0 failed for size" + fails + ".")
+